//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CCanvasTextBoard.h>
///	@path	~/src/graphics/canvas/
///	@date	2007/12/24
///	@desc	.

#pragma once

#include "xeres.h"

#include <deque>

#include "lib/system/lock.h"
#include "lib/math/rect.h"

#include "graphics/ICanvasElement.h"

namespace xeres {

	/*!
		\struct	TextBoardLine
		\brief	A line of text in text board.
	*/
	struct TextBoardLine
	{
		PackColor4		color;
		WString			line;
		int				top;
		int				bottom;	
	};

	/*!
		\class	CCanvasTextBoard
		\brief
	*/
	class CCanvasTextBoard : public ICanvasElement
	{
	public:

		/// \ctor
		CCanvasTextBoard( RefWeak<IFont> font , std::deque<TextBoardLine> * lines );

		/// \dtor
		virtual ~CCanvasTextBoard( void );

		DECL_IOBJECT_CLASS( CCanvasTextBoard , ICanvasElement );

	public:

	//@ interface

		/*!
			\brief		Render Canvas element.
		*/
		virtual void Render( RenderContext& rc , RefWeak<ISprite> sprite );

	//@ local

		/*!
			\brief
		*/
		void SetRect( const Rect<int>& rect );

	private:

		// process line
		bool DrawLine( TextBoardLine& line , Rect<int>& rect , RefWeak<ISprite> sprite , HDC dc );

	//@ data

		int							m_startingLine;
		int							m_spacing;
		std::deque<TextBoardLine> *	m_lines;

		ThreadLock					m_lock;
		Ref<IFont>					m_font;

		Rect<int>					m_rect;
	};

} // namespace xeres
